package day10;

/**
 *
 * @since 09:33
 * @author wuguidong@cskaoyan.onaliyun.com
 */
public class Demo {
    public static void main(String[] args) {
        Student s = new Student("123");
    }
}

class StudentFather {
    // int var = 18;
}

/*class Student extends StudentFather {
    int age;
    String name;
    static int var = 18;
    static {
        var = 100;
    }

    public Student() {
    }

    public Student(int age) {
        this.age = age;
    }

    public Student(String name) {
        // this(0);
        // Cannot reference 'Student.var' before supertype constructor has been called
        // 父类的构造器都还没执行,子类的成员变量赋值一定还未开始
        // this(var);

        // 需要一个赋值已经开始,甚至已经结束的变量var,是一个静态成员变量
        this(var);
        this.name = name;
    }
}*/

class Student {
    int age;
    String name;
    static int var = 100;

    {
        var = 200;
    }

    public Student() {
    }

    public Student(int age) {
        this.age = age;
    }

    public Student(String name) {
        /*
            var是自身类的成员变量
            这时它只有默认值0
            而且它的赋值还没有开始，永远等于0
         */
        // Cannot reference 'Student.var' before supertype constructor has been called
        this(var);
        this.name = name;
    }
}